package gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.net.URL;

import javax.help.HelpSet;
import javax.help.JHelp;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

/**
 * Generiert die Hilfe
 * 
 * @author Michi
 * 
 */
public class Help extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7377522936430969995L;
	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	// public static void main(String[] args) {
	// EventQueue.invokeLater(new Runnable() {
	// public void run() {
	// try {
	// Help frame = new Help();
	// frame.setVisible(true);
	// } catch (Exception e) {
	// e.printStackTrace();
	// }
	// }
	// });
	// }

	/**
	 * Create the frame.
	 */
	public Help(Test test) {

		JHelp helpViewer = null;
		try {
			// Hauptfenster in der nächsten Zeile ersetzen durch aktuellen
			// Klassennamen
			ClassLoader cl = Help.class.getClassLoader();
			URL url = HelpSet.findHelpSet(cl, "jhelpset.hs");
			helpViewer = new JHelp(new HelpSet(cl, url));
			// Darzustellendes Kapitel festlegen, ID muss im XML existieren!
			// 0 -> kalender 1-> kontakte 2-> todo 3-> mail
			if (test.getTabbedPane().getSelectedIndex() == 0) {
				helpViewer.setCurrentID("2");
			} else if (test.getTabbedPane().getSelectedIndex() == 1) {
				helpViewer.setCurrentID("3");
			} else if (test.getTabbedPane().getSelectedIndex() == 2) {
				helpViewer.setCurrentID("4");
			} else if (test.getTabbedPane().getSelectedIndex() == 3) {
				helpViewer.setCurrentID("5");
			} else {
				helpViewer.setCurrentID("1");
			}
		} catch (Exception e) {
		}

		JFrame frame = new JFrame();
		frame.setTitle("Fireball Organizer Hilfe");
		frame.setSize(1200, 700);

		Dimension dim = new Dimension(1200, 700);

		frame.setPreferredSize(dim);
		frame.setMinimumSize(dim);
		frame.setMaximumSize(dim);
		frame.getContentPane().add(helpViewer);
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.setVisible(true);

		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		// setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
	}

}
